package ftp;

import it.sauronsoftware.ftp4j.FTPDataTransferListener;

import java.io.File;


public class FTPTransferListener implements FTPDataTransferListener {
 
	int totalTransfered = 0;
	public int getTotalTransfered() {
		return totalTransfered;
	}


	public int getPercentage() {
		return percentage;
	}


	public File getTransferFile() {
		return transferFile;
	}

	public int percentage = 0;
	long size = 0;
    File transferFile = null;
	  
	public FTPTransferListener(File transferFile) {
	 size = transferFile.length();
	 this.transferFile = transferFile;
	}
	
  
	@Override
	public void aborted() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void completed() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void failed() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void started() {}

	@Override
	public void transferred(int transferred) {
		totalTransfered  += transferred;
		percentage =  (int) (totalTransfered * 100.0 / size); 
		FTPController.update(this);
		
	}

}
